package com.gexiao.expand.beans.factory;

import cn.hutool.core.lang.Console;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.stereotype.Component;

import java.util.Arrays;

@Component
public class MyBeanFactoryPostProcessor implements BeanFactoryPostProcessor {

    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        int definitionCount = beanFactory.getBeanDefinitionCount();
        Console.log("MyBeanFactoryPostProcessor#postProcessBeanFactory，当前factory中有{}个bean",definitionCount);
        Arrays.stream(beanFactory.getBeanDefinitionNames()).forEach(System.out::println);
    }


}
